<template>
  <el-container>
    <el-header>
      <h2>数据概览</h2>
    </el-header>
    <el-main v-if="source != null && this.source.length > 0">
      <br />
    </el-main>
  </el-container>
</template>

<script>
import { getDateRange } from "@/utils/date.js";
export default {
  components: {
  },
  computed: {
    source() {
      return this.$store.getters.summarySource;
    },
  },
  methods: {
    getDateRange,
    order(src, key = "value", reverse = false) {
      for (var i = 0; i < src.length - 1; i++) {
        // 内层循环,控制比较的次数，并且判断两个数的大小
        for (var j = 0; j < src.length - 1 - i; j++) {
          // 白话解释：如果前面的数大，放到后面(当然是从小到大的冒泡排序)
          if (src[j] > src[j + 1]) {
            var temp = src[j];
            src[j] = src[j + 1];
            src[j + 1] = temp;
          }
        }
      }
      return { key, reverse };
    },
    countSourcePerson(range) {
      let rows = {};
      for (let i = 0; i < this.source.length; i++) {
        let time = new Date(
          this.source[i].eventTime.replace(/-/g, "/")
        ).getTime();
        if (time <= range.max.getTime() && time >= range.min.getTime()) {
          if (!rows[this.source[i].clientName]) {
            rows[this.source[i].clientName] = 0;
          }
          rows[this.source[i].clientName]++;
        }
      }
      return rows;
    },
  },
  mounted() {},
};
</script>
